< previous page page_34 next page >

Page 34
Because the data displayed in FlexGrid controls can't be modified directly in the grid cells, this control would require several routines to be coded for users to manipulate data. If your application requires a display-only type of format, however, you can use a FlexGrid control. The most common task you'll perform when working with a grid is setting or retrieving the value in a cell. In the FlexGrid control, the contents of all cells are treated as text stringsmeaning that any data is allowed in the cell, and you must perform the appropriate edits to ensure that the correct data is being retrieved or set in the cell.
The MSFlexGrid
Three properties are available that you can use when working with cells in the FlexGrid control: Text, TextArray, and TextMatrix. You can use each property to retrieve or set the value of a single cell.
When used to retrieve a value, the Text property returns the value of the current cell. The current cell is defined by the current setting of the Row and Col properties. The following code shows how you would retrieve the value of the cell in the second row and second column of the grid:
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 1
txtReturn = MSFlexGrid1.Text
Note
Row and column values start at zero for the FlexGrid and DBGrid controls.

The TextArray property provides a different way of accessing the value of a cell. You can use TextArray to retrieve the value of any cell, not just the current cell. This makes it easier to use than the Text property when working with multiple cells. The TextArray property uses a single index value to specify the required cell. This index is determined by multiplying the desired row number by the number of columns in the grid, and then adding the desired column number. The following code shows how to retrieve the same value as the preceding example:
intGetColumn = 1

 
< previous page page_34 next page >

If you like this book, buy it!